package com.ctgu.rabbitmq.rabbitmq.queue.queueExpired;

import lombok.extern.log4j.Log4j2;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @ ClassName QueueExpiredConsumer
 * @ Author Alex2
 * @ Date 2025/8/15 11:21
 **/
@Log4j2
@Component
public class QueueExpiredConsumer {

    private static final String TAG = "Alex";

    //不启动消费普通队列的消费者，让消息在队列中自然过期，然后进入 DLX

    // 死信队列消费
    @RabbitListener(queues = QueueExpiredConfig.DLX_QUEUE_QUEUE_EXPIRED)
    public void consumeDLX(Message message) {
        String body = new String(message.getBody());
        log.debug("{} : 死信队列收到消息 : {}", TAG, body);
    }
}